package com.swiot.quartz.service.impl;

import com.swiot.common.utils.StringUtils;
import com.swiot.quartz.domain.SysJob;
import com.swiot.quartz.service.ISysJobExtendService;
import com.swiot.quartz.service.ISysJobService;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;

public class SysJobExtendServiceImpl implements ISysJobExtendService {
    @Autowired
    private ISysJobService jobService;

    @Override
    public boolean runJob(String jobId, String target) throws SchedulerException {
        if (StringUtils.isEmpty(jobId)) {
            return false;
        }
        SysJob job = new SysJob();
        job.setJobId(Long.valueOf(jobId));
        job.setJobGroup("DEFAULT");
        job.setInvokeTarget(target);
        return jobService.run(job);
    }
}
